// 加载模块
const mongoose = require('mongoose')

// 连接数据库
mongoose.connect('mongodb://localhost/webshop',{ useNewUrlParser: true, useUnifiedTopology: true })

// 监听连接状态
mongoose.connection.on('error',console.error.bind(console, 'connection error:'))
mongoose.connection.on('open',()=>{
    console.log( '---------------mongodb ok---------------' )
})

module.exports = mongoose.connection
